import json

from files.file_json_global import FileJsonGlobal


class PublicGlobals:        # 全局变量类----用于跨用例传输变量
    sn_Seq:str = ''             # 产品SN号
    stationID:int = 0           # 工站ID----当前要过的是第几工站
    MES_Enable:bool = False     # 是否上传数据给mes服务器，False表示不上传，True表示上传
    url:str = ''                # 访问接口的网址
    serial_handle_0 = 'com12'   # 1-串口句柄
    serial_handle_1 = None      # 1-串口句柄
    int_temp_0:int = 1
    int_temp_1:int = 0
    int_temp_2:int = 0
    str_temp_0:str = '4b:90:14:81:fe:e0'        # VX989地址
    str_temp_1:str = ''
    str_temp_2:str = ''
    bool_temp_0:bool = False
    bool_temp_1:bool = False
    bool_temp_2:bool = False
    pass

    @classmethod
    def init(cls):
        data: dict = FileJsonGlobal.read_json_global()
        for key,value in data.items():
            setattr(cls, key, value)


# if __name__ == '__main__':
#     # d:dict = FileJsonGlobal.read_json_global()
#     with open('../datafiles/global.json', 'r', encoding='utf-8') as f:
#         data:dict = json.load(f)
#     print(data)
#     for key,value in data.items():
#         # PublicGlobals.__dict__[key] = value
#         setattr(PublicGlobals, key, value)
#     print(PublicGlobals.__dict__)









